<!--
  Copyright 2013-2018 the original author or authors.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<div class="card">
  <div class="card-header">
    <h2>UI Defaults</h2>
  </div>
  <div class="card-body">
    <div ng-hide="hideMainContent()">
      <div ng-include src="'template/gt-loading-overlay.html'"></div>
      <div ng-include src="'template/gt-http-error-overlay.html'"></div>
      <form gt-form-autofocus-on-first-input
            name="formCtrl"
            style="padding-top: 15px;"
            novalidate>
        <div class="form-group row">
          <label class="col-xl-3 gt-form-label-xl"
                 for="defaultTransactionType">
            Default transaction type
          </label>
          <div class="col-xl-9">
            <select ng-model="config.defaultTransactionType"
                    ng-disabled="!agentRollup.permissions.config.edit.uiDefaults"
                    id="defaultTransactionType"
                    class="custom-select"
                    style="width: auto;">
              <option ng-repeat="transactionType in allTransactionTypes track by transactionType.name"
                      ng-value="transactionType.name"
                      ng-disabled="transactionType.disabled">
                {{transactionType.name}}
              </option>
            </select>
            <div class="help-block">
              The default transaction type displayed on the transactions and errors page.
            </div>
          </div>
        </div>
        <div gt-form-group
             gt-label="Default percentiles"
             gt-model="page.defaultPercentiles"
             gt-pattern="pattern.percentageList"
             gt-required="loaded"
             gt-disabled="!agentRollup.permissions.config.edit.uiDefaults"
             gt-width="20em">
          <div class="help-block">
            The default percentiles displayed on the transaction percentiles tab.
            <a href="http://hdrhistogram.github.io/HdrHistogram/">HdrHistogram</a> is used to bucket and store the
            full range of values so that any percentile value can be reported with at most 1% error,
            e.g. if the 99.9<sup>th</sup> percentile is reported as 1400 milliseconds, then that would be at most
            14 milliseconds from the true 99.9<sup>th</sup> percentile value.
          </div>
        </div>
        <div class="form-group row">
          <label class="col-xl-3 gt-form-label-xl"
                 for="defaultGaugeNames">
            Default gauges
          </label>
          <div class="col-xl-9">
            <select multiple
                    ng-model="config.defaultGaugeNames"
                    ng-disabled="!agentRollup.permissions.config.edit.uiDefaults"
                    id="defaultGaugeNames"
                    class="form-control"
                    style="width: auto; height: 200px; border-top-right-radius: 0; border-bottom-right-radius: 0;">
              <option ng-repeat="gauge in allGauges"
                      ng-value="gauge.name"
                      ng-disabled="gauge.disabled">
                {{gauge.display}}
              </option>
            </select>
            <div class="help-block">
              The default gauges displayed on the JVM gauges page.
            </div>
          </div>
        </div>
        <div class="form-group row"
             ng-if="agentRollup.permissions.config.edit.uiDefaults">
          <div class="offset-xl-3 col-xl-9">
            <div gt-button
                 gt-label="Save changes"
                 gt-click="save(deferred)"
                 gt-validate-form="formCtrl">
            </div>
          </div>
        </div>
      </form>
    </div>
  </div>
</div>
<!-- each page with confirmation dialog needs its own confirmation dom so that it is deleted on $destroy -->
<div ng-include="'template/gt-confirmation.html'"></div>
